\(\int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx\) [527]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 47 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {b^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \cos (c+d x)}{d}+\frac {\left (a^2-b^2\right ) \sin (c+d x)}{d} \]

[Out]

b^2*arctanh(sin(d*x+c))/d-2*a*b*cos(d*x+c)/d+(a^2-b^2)*sin(d*x+c)/d

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.00, number of steps used = 1, number of rules used = 1, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.053, Rules used = {3588} \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (a^2-b^2\right ) \sin (c+d x)}{d}-\frac {2 a b \cos (c+d x)}{d}+\frac {b^2 \text {arctanh}(\sin (c+d x))}{d} \]

[In]

Int[Cos[c + d*x]*(a + b*Tan[c + d*x])^2,x]

[Out]

(b^2*ArcTanh[Sin[c + d*x]])/d - (2*a*b*Cos[c + d*x])/d + ((a^2 - b^2)*Sin[c + d*x])/d

Rule 3588

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^2/sec[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[b^2*(ArcTanh[Sin[e + f
*x]]/f), x] + (-Simp[2*a*b*(Cos[e + f*x]/f), x] + Simp[(a^2 - b^2)*(Sin[e + f*x]/f), x]) /; FreeQ[{a, b, e, f}
, x] && NeQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {b^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {2 a b \cos (c+d x)}{d}+\frac {\left (a^2-b^2\right ) \sin (c+d x)}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.58 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.79 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {-2 a b \cos (c+d x)+b^2 \left (-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+\left (a^2-b^2\right ) \sin (c+d x)}{d} \]

[In]

Integrate[Cos[c + d*x]*(a + b*Tan[c + d*x])^2,x]

[Out]

(-2*a*b*Cos[c + d*x] + b^2*(-Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2
]]) + (a^2 - b^2)*Sin[c + d*x])/d

Maple [A] (verified)

Time = 1.18 (sec) , antiderivative size = 53, normalized size of antiderivative = 1.13

method result size
derivativedivides \(\frac {b^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-2 a b \cos \left (d x +c \right )+a^{2} \sin \left (d x +c \right )}{d}\) \(53\)
default \(\frac {b^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-2 a b \cos \left (d x +c \right )+a^{2} \sin \left (d x +c \right )}{d}\) \(53\)
risch \(-\frac {{\mathrm e}^{i \left (d x +c \right )} a b}{d}-\frac {i a^{2} {\mathrm e}^{i \left (d x +c \right )}}{2 d}+\frac {i {\mathrm e}^{i \left (d x +c \right )} b^{2}}{2 d}-\frac {{\mathrm e}^{-i \left (d x +c \right )} a b}{d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} a^{2}}{2 d}-\frac {i {\mathrm e}^{-i \left (d x +c \right )} b^{2}}{2 d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2}}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2}}{d}\) \(147\)

[In]

int(cos(d*x+c)*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2*(-sin(d*x+c)+ln(sec(d*x+c)+tan(d*x+c)))-2*a*b*cos(d*x+c)+a^2*sin(d*x+c))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 62, normalized size of antiderivative = 1.32 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {4 \, a b \cos \left (d x + c\right ) - b^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) + b^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) - 2 \, {\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}{2 \, d} \]

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(4*a*b*cos(d*x + c) - b^2*log(sin(d*x + c) + 1) + b^2*log(-sin(d*x + c) + 1) - 2*(a^2 - b^2)*sin(d*x + c)
)/d

Sympy [F]

\[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \cos {\left (c + d x \right )}\, dx \]

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*cos(c + d*x), x)

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.28 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {b^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right ) - 2 \, \sin \left (d x + c\right )\right )} - 4 \, a b \cos \left (d x + c\right ) + 2 \, a^{2} \sin \left (d x + c\right )}{2 \, d} \]

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/2*(b^2*(log(sin(d*x + c) + 1) - log(sin(d*x + c) - 1) - 2*sin(d*x + c)) - 4*a*b*cos(d*x + c) + 2*a^2*sin(d*x
 + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1100 vs. \(2 (47) = 94\).

Time = 0.70 (sec) , antiderivative size = 1100, normalized size of antiderivative = 23.40 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\text {Too large to display} \]

[In]

integrate(cos(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/2*(b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 + 2*tan(1/2*d*x)^2*tan(1/2*c) + 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan
(1/2*d*x)^2 + tan(1/2*c)^2 - 2*tan(1/2*d*x) - 2*tan(1/2*c) + 1)/(tan(1/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2
+ tan(1/2*c)^2 + 1))*tan(1/2*d*x)^2*tan(1/2*c)^2 - b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 - 2*tan(1/2*d*x)^2*t
an(1/2*c) - 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 2*tan(1/2*d*x) + 2*tan(1/2*c) + 1)/(
tan(1/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*d*x)^2*tan(1/2*c)^2 + 4*a*b*tan(1/2*
d*x)^2*tan(1/2*c)^2 + b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 + 2*tan(1/2*d*x)^2*tan(1/2*c) + 2*tan(1/2*d*x)*ta
n(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 - 2*tan(1/2*d*x) - 2*tan(1/2*c) + 1)/(tan(1/2*d*x)^2*tan(1/2*c)^2 +
 tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*d*x)^2 - b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 - 2*tan(1/2*d*x)^
2*tan(1/2*c) - 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 2*tan(1/2*d*x) + 2*tan(1/2*c) + 1
)/(tan(1/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*d*x)^2 + 4*a^2*tan(1/2*d*x)^2*tan
(1/2*c) - 4*b^2*tan(1/2*d*x)^2*tan(1/2*c) + b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 + 2*tan(1/2*d*x)^2*tan(1/2*
c) + 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 - 2*tan(1/2*d*x) - 2*tan(1/2*c) + 1)/(tan(1/2
*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*c)^2 - b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)
^2 - 2*tan(1/2*d*x)^2*tan(1/2*c) - 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 2*tan(1/2*d*x
) + 2*tan(1/2*c) + 1)/(tan(1/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*c)^2 + 4*a^2*
tan(1/2*d*x)*tan(1/2*c)^2 - 4*b^2*tan(1/2*d*x)*tan(1/2*c)^2 - 4*a*b*tan(1/2*d*x)^2 - 16*a*b*tan(1/2*d*x)*tan(1
/2*c) - 4*a*b*tan(1/2*c)^2 + b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 + 2*tan(1/2*d*x)^2*tan(1/2*c) + 2*tan(1/2*
d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 - 2*tan(1/2*d*x) - 2*tan(1/2*c) + 1)/(tan(1/2*d*x)^2*tan(1/2
*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1)) - b^2*log(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 - 2*tan(1/2*d*x)^2*tan(1/
2*c) - 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 2*tan(1/2*d*x) + 2*tan(1/2*c) + 1)/(tan(1
/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1)) - 4*a^2*tan(1/2*d*x) + 4*b^2*tan(1/2*d*x) - 4*a^2
*tan(1/2*c) + 4*b^2*tan(1/2*c) + 4*a*b)/(d*tan(1/2*d*x)^2*tan(1/2*c)^2 + d*tan(1/2*d*x)^2 + d*tan(1/2*c)^2 + d
)

Mupad [B] (verification not implemented)

Time = 4.97 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.40 \[ \int \cos (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2\,b^2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d}-\frac {4\,a\,b-\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (2\,a^2-2\,b^2\right )}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )} \]

[In]

int(cos(c + d*x)*(a + b*tan(c + d*x))^2,x)

[Out]

(2*b^2*atanh(tan(c/2 + (d*x)/2)))/d - (4*a*b - tan(c/2 + (d*x)/2)*(2*a^2 - 2*b^2))/(d*(tan(c/2 + (d*x)/2)^2 +
1))